﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace BesAsm.Stormwater.Swmm5Results
{
  public class NodeVariables : ResultVariablesBase, IName
  {
    public ResultVariable Depth = new ResultVariable("Depth", 0);
    public ResultVariable HydraulicHead = new ResultVariable("HydraulicHead", 4);
    public ResultVariable VolumeStoredAndPonded = new ResultVariable("VolumeStoredAndPonded", 8);
    public ResultVariable LateralInflow = new ResultVariable("LateralInflow", 12);
    public ResultVariable TotalInflow = new ResultVariable("TotalInflow", 16);
    public ResultVariable FlowLostToFlooding = new ResultVariable("FlowLostToFlooding", 20);

    public float NodeType { get; internal set; }
    public float Invert { get; internal set; }
    public float MaxDepth { get; internal set; }

    public NodeVariables(string name, OutputFileReader reader)
    {
      _reader = reader;
      _name = name;
      _variables.Add(Depth);
      _variables.Add(HydraulicHead);
      _variables.Add(VolumeStoredAndPonded);
      _variables.Add(LateralInflow);
      _variables.Add(TotalInflow);
      _variables.Add(FlowLostToFlooding);
    }

    protected override int GetElementPosition()
    {
      return _reader.NodePosition[Name];
    }

    public void LoadDepth(bool close)
    {
      Depth.SetData(
        LoadResult(Depth.Position, close));
      Depth.IsLoaded = true;
    }
    public void LoadHydraulicHead(bool close)
    {
      HydraulicHead.SetData(
        LoadResult(HydraulicHead.Position, close));
      HydraulicHead.IsLoaded = true;
    }
    public void LoadVolumeStoredAndPonded(bool close)
    {
      VolumeStoredAndPonded.SetData(
        LoadResult(VolumeStoredAndPonded.Position, close));
      VolumeStoredAndPonded.IsLoaded = true;
    }
    public void LoadLateralInflow(bool close)
    {
      LateralInflow.SetData(
        LoadResult(LateralInflow.Position, close));
      LateralInflow.IsLoaded = true;
    }
    public void LoadTotalInflow(bool close)
    {
      TotalInflow.SetData(
        LoadResult(TotalInflow.Position, close));
      TotalInflow.IsLoaded = true;
    }
    public void LoadFlowLostToFlooding(bool close)
    {
      FlowLostToFlooding.SetData(
        LoadResult(FlowLostToFlooding.Position, close));
      FlowLostToFlooding.IsLoaded = true;
    }

  }

}
